/**
 * 图片资源转成Base64数据
 * author  y/m/d
 * @flow
 */
import React, { PureComponent } from 'react';
import {
    NativeModules,
} from 'react-native';
const RNImageToBase64 = NativeModules.RNImageToBase64;

class ImageToBase64 {
     /**
     * 图片转base64数据
     * @param uri
      * @param callBack --err,base64Data
     * @constructor
     */
     static ImageToBase64ByUri(uri,callBack){
        RNImageToBase64.getBase64String(uri, (err, base64) => {
            // Do something with the base64 string
            if(err){
                callBack(err,base64);
            } else {
                callBack(err,base64);
            }
        });
    }
}

export default ImageToBase64;
